/*
 * Copyright (c) 2023, 2023,yzc.cn All rights reserved.
 *
 */
package cn.yzc.mapper;

import cn.yzc.pojo.Role;
import cn.yzc.pojo.User;
import org.apache.ibatis.annotations.Many;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>Project: mybatis_pro - UserMapper.xml</p>
 * <p>Powered by yzc On 2023-10-10 20:55:27</p>
 * <p>描述：<p>
 *
 * @author yzc [yzc0415@126.com]
 * @version 1.0
 * @since 17
 */
public interface UserMapper {

    List<Role> queryUser(int id);

    @Select("select id ,name from user where id=#{id}")
    @Results({
            @Result(property = "id", column = "id"),
            @Result(property = "name", column = "name"),
            @Result(property = "roleList", column = "id", javaType = List.class,
                    many = @Many(select = "cn.yzc.mapper.UserMapper.queryUR"))
    })
    List<User> queryUser1(int id);

    @Select("select id, roleName from role left join user_role ur  on id = rid where uid=#{id}")
    List<Role> queryUR(int id);
}
